package com.dependencies.springdatajpa.service;

import com.dependencies.springdatajpa.entity.UserEntity;
import com.dependencies.springdatajpa.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author zhizhou   2024/7/30 23:24
 */
@Service
public class UserService {
    
    @Autowired
    private UserRepository userRepository;
    
    public List<UserEntity> getAllUsers() {
        return userRepository.findAll();
    }
    
    public UserEntity save(UserEntity userEntity) {
        return userRepository.save(userEntity);
    }
    
    public void delete(Long id) {
        userRepository.deleteById(id);
    }
}
